package com.itheima_05;

import java.util.Scanner;

/**
 * @author Xiao
 * @date 2021/7/5
 */
@SuppressWarnings("all")    //压制所有警告
public class toCharArrayString {
    /**
        统计字符次数：
            键盘录入一个字符串，
            统计该字符串中大写字母字符，小写字母字符，数字字符出现的次数（不考虑其他字母）。
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串");
        String s = sc.nextLine();
        System.out.println("------------");
        char[] ch = s.toCharArray();
        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        for (int i = 0; i < ch.length; i++) {
            if (ch[i] >= 'A' && ch[i] <= 'Z') {
                count1++;
            } else if (ch[i] >= 'a' && ch[i] <= 'z') {
                count2++;
            } else if (ch[i] >= '0' && ch[i] <= '9') {
                count3++;
            }
        }
        System.out.println("count('A'-'Z')：" + count1);
        System.out.println("count('a'-'z')：" + count2);
        System.out.println("count('0'-'9')：" + count3);
    }
}
